#include<bits/stdc++.h>
using namespace std;
int a[2000],b[2000],c[2000];
struct Arrow
{
	int a,b,c;
	bool operator < (const Arrow &x) const
	{
		return a-c<x.a-x.c;
	}
}arrow[2000];
int main()
{
	int T,n,t;
	cin>>T;
	while(T--)
	{
		cin>>n;
		int cnt=0,sumC=0;
		for(int i=1;i<=n;i++)
		{
			cin>>arrow[i].a>>arrow[i].b>>arrow[i].c;
			sumC+=arrow[i].c;
		}
		cin>>t;
		if(t<sumC)
		{
			cout<<"Oh,my god!"<<endl;
			continue;
		}
		t-=sumC;
		sort(arrow+1,arrow+n+1);
		for(int i=1;i<=n;i++)
		{
			if(t<arrow[i].a-arrow[i].c)
				break;
			t-=arrow[i].a-arrow[i].c;
			cnt++;
		}
		cout<<cnt<<endl;
	}
    return 0;
}
